<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 15-1-8
 * Time: 下午6:00
 * 状态管理
 */
namespace Factory\Controller;
use Mcit\Page;
class StateController extends BaseController {
    //首页
    public function index(){

        $key_link = I("key_link");

        //2---厂商  3---运营商
        if(session("fac_type") == 2){
            if (session('fac_key')){
                $condition_str="b.ev_fac_code='".session('fac_key')."' and c.yy_user_id='".session('uid')."'";
            }else{$condition_str="b.ev_fac_code='".session('fac_login_name')."'";}
        }elseif(session("fac_type") == 3){
            if(session('pid') != 0){
                $operation = "c.plant_attr=3 and c.yy_user_id='".session('uid')."'";
            }else{
                $yyuserid = M()->query("select id from ev_fac where id='".session('uid')."' OR pid='".session('uid')."'");
                foreach($yyuserid as $k=>$v){
                    $yyuserids .= $v['id'].",";
                }
                $yyuserids = trim($yyuserids,',');
                $operation = "c.plant_attr=3 and c.yy_user_id IN($yyuserids)";
            }
        }

        //P($_SESSION);
        if(isset($_GET['charge']) && $_GET['charge'] == 1){//充电中
            $sql = "select * from char_state_now a
                    left join ev_char b
                    on b.key_link = a.key_link
                    left join ev_plant c
                    on c.id = b.ev_plant_id
                    where {$condition_str} {$operation}
                    and a.charge = 1
                    and a.bespeak = 0
                    and a.error = 0
                    and a.cable = 0";
            $this->charge  = count(M()->query($sql));//充电中
            $this->release = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}
                                                and a.charge = 0
                                                and a.bespeak = 0
                                                and a.error = 0
                                                and a.cable = 0"));//空闲
            $this->error   = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}
                                                and a.charge = 0
                                                and a.bespeak = 0
                                                and a.error = 1
                                                and a.cable = 0"));//下线
            $this->count   = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}"));//总数
            if(!empty($_GET['location_t_1'])){
                if(I('location_s_1') == 110100 || I('location_s_1') == 120100 || I('location_s_1') == 310100 || I('location_s_1') == 500100){
                    if(I('location_s_1') == I('location_t_1')-1){
                        $location = I('location_f_1').",".I('location_s_1');
                    }else{
                        $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                    }
                }else if(I('location_s_1') == I('location_t_1')-1){
                    $location = I('location_f_1').",".I('location_s_1');
                }else{
                    $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                }
                $sql = "select * from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and a.charge = 1
                and a.error = 0
                and a.bespeak = 0
                and a.cable = 0
                and c.location like '$location%'";
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.charge = 1
                         and a.error = 0
                         and a.bespeak = 0
                         and a.cable = 0";
                $this->charge  = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.charge = 0
                         and a.bespeak = 0
                         and a.error = 0
                         and a.cable = 0";
                $this->release = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.error = 1
                         and a.charge = 0
                         and a.cable = 0
                         and a.bespeak = 0";
                $this->error   = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'";
                $this->count   = count(M()->query($sql8));//总数
            }
            $this->control = "充电中";
        }elseif(isset($_GET['charge']) && $_GET['charge'] == 0){//空闲
            $sql = "select * from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and a.charge = 0
                and a.bespeak = 0
                and a.cable = 0
                and a.error = 0";
            $this->charge  = count(M()->query($sql));//充电中
            $this->release = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}
                                                and a.charge = 0
                                                and a.bespeak = 0
                                                and a.error = 0
                                                and a.cable = 0"));//空闲
            $this->error   = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}
                                                and a.charge = 0
                                                and a.bespeak = 0
                                                and a.error = 1
                                                and a.cable = 0"));//下线
            $this->count   = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}"));//总数
            if(!empty($_GET['location_t_1'])){
                if(I('location_s_1') == 110100 || I('location_s_1') == 120100 || I('location_s_1') == 310100 || I('location_s_1') == 500100){
                    if(I('location_s_1') == I('location_t_1')-1){
                        $location = I('location_f_1').",".I('location_s_1');
                    }else{
                        $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                    }
                }else if(I('location_s_1') == I('location_t_1')-1){
                    $location = I('location_f_1').",".I('location_s_1');
                }else{
                    $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                }
                $sql = "select * from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and a.charge = 0
                and a.bespeak = 0
                and a.cable = 0
                and a.error = 0
                and c.location like '$location%'";
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.charge = 1
                         and a.bespeak = 0
                         and a.cable = 0
                         and a.error = 0";
                $this->charge  = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.charge = 0
                         and a.bespeak = 0
                         and a.cable = 0
                         and a.error = 0";
                $this->release = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.error = 1
                         and a.charge = 0
                         and a.bespeak = 0
                         and a.cable = 0";
                $this->error   = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'";
                $this->count   = count(M()->query($sql8));//总数
            }
            $this->control = "空闲";
        }elseif(isset($_GET['error']) && $_GET['error'] ==1){//故障状态
            $sql = "select * from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and a.error = 1
                and a.charge = 0
                and a.bespeak = 0
                and a.cable = 0";
            $this->charge  = count(M()->query($sql));//充电中
            $this->release = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}
                                                and a.charge = 0
                                                and a.bespeak = 0
                                                and a.error = 0
                                                and a.cable = 0"));//空闲
            $this->error   = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}
                                                and a.charge = 0
                                                and a.bespeak = 0
                                                and a.error = 1
                                                and a.cable = 0"));//下线
            $this->count   = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}"));//总数
            if(!empty($_GET['location_t_1'])){
                if(I('location_s_1') == 110100 || I('location_s_1') == 120100 || I('location_s_1') == 310100 || I('location_s_1') == 500100){
                    if(I('location_s_1') == I('location_t_1')-1){
                        $location = I('location_f_1').",".I('location_s_1');
                    }else{
                        $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                    }
                }else if(I('location_s_1') == I('location_t_1')-1){
                    $location = I('location_f_1').",".I('location_s_1');
                }else{
                    $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                }
                $sql = "select * from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where a.error = 1
                and a.charge = 0
                and a.bespeak = 0
                and a.cable = 0
                and {$condition_str} {$operation}
                and c.location like '$location%'";
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.charge = 1
                         and a.error = 0
                         and a.bespeak = 0
                         and a.cable = 0";
                $this->charge  = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.charge = 0
                         and a.bespeak = 0
                         and a.cable = 0
                         and a.error = 0";
                $this->release = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.error = 1
                         and a.bespeak = 0
                         and a.cable = 0
                         and charge = 0";
                $this->error   = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'";
                $this->count   = count(M()->query($sql8));//总数
            }
            $this->control = "故障";
        }elseif(!empty($_GET['key_link'])){
            $sql = "select * from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and a.key_link  like '$key_link%'";
            $this->charge  = count(M()->query($sql));//充电中
            $this->release = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}
                                                and a.key_link  like '$key_link%'
                                                and a.charge = 0
                                                and a.bespeak = 0
                                                and a.error = 0
                                                and a.cable = 0"));//空闲
            $this->error   = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}
                                                and a.key_link  like '$key_link%'
                                                and a.charge = 0
                                                and a.bespeak = 0
                                                and a.error = 1
                                                and a.cable = 0"));//下线
            $this->count   = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}
                                                and a.key_link  like '$key_link%'"));//总数
        }elseif(!empty($_GET['location_t_1'])){
            if(I('location_s_1') == 110100 || I('location_s_1') == 120100 || I('location_s_1') == 310100 || I('location_s_1') == 500100){
                if(I('location_s_1') == I('location_t_1')-1){
                    $location = I('location_f_1').",".I('location_s_1');
                }else{
                    $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                }
            }else if(I('location_s_1') == I('location_t_1')-1){
                $location = I('location_f_1').",".I('location_s_1');
            }else{
                $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
            }
            $sql = "select * from char_state_now a
            left join ev_char b
            on b.key_link = a.key_link
            left join ev_plant c
            on c.id = b.ev_plant_id
            where {$condition_str} {$operation}
            and c.location like '$location%'";
            $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.charge = 1
                         and a.bespeak = 0
                         and a.cable = 0
                         and a.error = 0";
            $this->charge  = count(M()->query($sql8));
            $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.charge = 0
                         and a.bespeak = 0
                         and a.cable = 0
                         and a.error = 0";
            $this->release = count(M()->query($sql8));
            $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.error = 1
                         and a.bespeak = 0
                         and a.charge = 0
                         and a.cable = 0";
            $this->error   = count(M()->query($sql8));
            $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'";
            $this->count   = count(M()->query($sql8));//总数
        }else{
            if(!empty($_GET['location_t_1'])){
                if(I('location_s_1') == 110100 || I('location_s_1') == 120100 || I('location_s_1') == 310100 || I('location_s_1') == 500100){
                    if(I('location_s_1') == I('location_t_1')-1){
                        $location = I('location_f_1').",".I('location_s_1');
                    }else{
                        $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                    }
                }else if(I('location_s_1') == I('location_t_1')-1){
                    $location = I('location_f_1').",".I('location_s_1');
                }else{
                    $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                }
                $sql = "select * from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and c.location like '$location%'";
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.charge = 1
                         and a.error = 0
                         and a.bespeak = 0
                         and a.cable = 0";
                $this->charge  = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.charge = 0
                         and a.bespeak = 0
                         and a.cable = 0
                         and a.error = 0";
                $this->release = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'
                         and a.charge = 0
                         and a.bespeak = 0
                         and a.cable = 0
                         and a.error = 1";
                $this->error   = count(M()->query($sql8));
                $sql8 = "select * from char_state_now a
                         left join ev_char b
                         on b.key_link = a.key_link
                         left join ev_plant c
                         on c.id = b.ev_plant_id
                         where {$condition_str} {$operation}
                         and c.location like '$location%'";
                $this->count   = count(M()->query($sql8));//总数
            }else{
                $sql = "select * from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}";
                $this->charge  = count(M()->query($sql));//充电中
                $this->release = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}
                                                and a.charge = 0
                                                and a.bespeak = 0
                                                and a.error = 0
                                                and a.cable = 0"));//空闲
                $this->error   = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}
                                                and a.charge = 0
                                                and a.bespeak = 0
                                                and a.error = 1
                                                and a.cable = 0"));//下线
                $this->count   = count(M()->query("select * from char_state_now a
                                                left join ev_char b
                                                on b.key_link = a.key_link
                                                left join ev_plant c
                                                on c.id = b.ev_plant_id
                                                where {$condition_str} {$operation}"));//总数
            }
        }
        //分页
        $count = count(M()->query($sql));
//        echo M()->getLastSql();
        // 重搜一律回第一页
        if( $_GET['fsign'] == "abnormal" ){
            $_GET['fsign'] = "normal";
            $_GET['page']  = 0;
        }
        vendor('Mcit.Sys.Page');
        $Page = new Page($count, 20);
        $pageView = $Page->show();
        $this->assign('pageView', $pageView); //发送分页
        if($_GET['page'] == 0){
            $nowPage = isset($_GET['page']) ? $_GET['page'] : 0;
        }else{
            $nowPage = isset($_GET['page']) ? $_GET['page'] * 20 - 20 : 0;
        }

        if(isset($_GET['charge']) && $_GET['charge'] == 1){//充电中
            $sql1 = "select a.id,a.key_link,a.charge,a.error,a.bespeak,a.cable,b.evc_number,c.name,c.location,a.now_user,b.charID,a.char_u,a.char_i,a.char_p,a.char_now_hour,a.char_now_minute,a.s_key_link
                from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where  {$condition_str} {$operation}
                and a.charge = 1
                and a.cable = 0
                and a.bespeak = 0
                and a.error = 0
                limit $nowPage,".$Page->listRows;
            if(!empty($_GET['location_t_1'])){
                if(I('location_s_1') == 110100 || I('location_s_1') == 120100 || I('location_s_1') == 310100 || I('location_s_1') == 500100){
                    if(I('location_s_1') == I('location_t_1')-1){
                        $location = I('location_f_1').",".I('location_s_1');
                    }else{
                        $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                    }
                }else if(I('location_s_1') == I('location_t_1')-1){
                    $location = I('location_f_1').",".I('location_s_1');
                }else{
                    $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                }
                $sql1 = "select a.id,a.key_link,a.charge,a.error,a.bespeak,a.cable,b.evc_number,c.name,c.location,a.now_user,b.charID,a.char_u,a.char_i,a.char_p,a.char_now_hour,a.char_now_minute,a.s_key_link
                from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and a.charge = 1
                and a.bespeak = 0
                and a.error = 0
                and a.cable = 0
                and c.location like '$location%'
                limit $nowPage,".$Page->listRows;
            }
            $this->control = "充电中";
        }elseif(isset($_GET['charge']) && $_GET['charge'] == 0){//空闲
            $sql1 = "select a.id,a.key_link,a.charge,a.error,a.bespeak,a.cable,b.evc_number,c.name,c.location,a.now_user,b.charID,a.char_u,a.char_i,a.char_p,a.char_now_hour,a.char_now_minute,a.s_key_link
                from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and a.charge = 0
                and a.bespeak = 0
                and a.error = 0
                and a.cable = 0
                limit $nowPage,".$Page->listRows;
            if(!empty($_GET['location_t_1'])){
                if(I('location_s_1') == 110100 || I('location_s_1') == 120100 || I('location_s_1') == 310100 || I('location_s_1') == 500100){
                    if(I('location_s_1') == I('location_t_1')-1){
                        $location = I('location_f_1').",".I('location_s_1');
                    }else{
                        $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                    }
                }else if(I('location_s_1') == I('location_t_1')-1){
                    $location = I('location_f_1').",".I('location_s_1');
                }else{
                    $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                }
                $sql1 = "select a.id,a.key_link,a.charge,a.error,a.bespeak,a.cable,b.evc_number,c.name,c.location,a.now_user,b.charID,a.char_u,a.char_i,a.char_p,a.char_now_hour,a.char_now_minute,a.s_key_link
                from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where a.charge = 0
                and a.error = 0
                and a.cable = 0
                and a.bespeak = 0
                and {$condition_str} {$operation}
                and c.location like '$location%'
                limit $nowPage,".$Page->listRows;
            }
            $this->control = "空闲";
        }elseif(isset($_GET['error']) && $_GET['error'] ==1){//故障状态
            $sql1 = "select a.id,a.key_link,a.charge,a.error,a.bespeak,a.cable,b.evc_number,c.name,c.location,a.now_user,b.charID,a.char_u,a.char_i,a.char_p,a.char_now_hour,a.char_now_minute,a.s_key_link
                from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and a.error = 1
                and a.charge = 0
                and a.bespeak = 0
                and a.cable = 0
                limit $nowPage,".$Page->listRows;
            if(!empty($_GET['location_t_1'])){
                if(I('location_s_1') == 110100 || I('location_s_1') == 120100 || I('location_s_1') == 310100 || I('location_s_1') == 500100){
                    if(I('location_s_1') == I('location_t_1')-1){
                        $location = I('location_f_1').",".I('location_s_1');
                    }else{
                        $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                    }
                }else if(I('location_s_1') == I('location_t_1')-1){
                    $location = I('location_f_1').",".I('location_s_1');
                }else{
                    $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                }
                $sql1 = "select a.id,a.key_link,a.charge,a.error,a.bespeak,a.cable,b.evc_number,c.name,c.location,a.now_user,b.charID,a.char_u,a.char_i,a.char_p,a.char_now_hour,a.char_now_minute,a.s_key_link
                from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and a.error = 1
                and a.charge = 0
                and a.bespeak = 0
                and a.cable = 0
                and c.location like '$location%'
                limit $nowPage,".$Page->listRows;
            }
            $this->control = "故障";
        }elseif(!empty($_GET['key_link'])){
            $sql1 = "select a.id,a.key_link,a.charge,a.error,a.bespeak,a.cable,b.evc_number,c.name,c.location,a.now_user,b.charID,a.char_u,a.char_i,a.char_p,a.char_now_hour,a.char_now_minute,a.s_key_link
                from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and a.key_link like '$key_link%'
                limit $nowPage,".$Page->listRows;
        }elseif(!empty($_GET['location_t_1'])){
            if(I('location_s_1') == 110100 || I('location_s_1') == 120100 || I('location_s_1') == 310100 || I('location_s_1') == 500100){
                if(I('location_s_1') == I('location_t_1')-1){
                    $location = I('location_f_1').",".I('location_s_1');
                }else{
                    $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                }
            }else if(I('location_s_1') == I('location_t_1')-1){
                $location = I('location_f_1').",".I('location_s_1');
            }else{
                $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
            }
            $sql1 = "select a.id,a.key_link,a.charge,a.error,a.bespeak,a.cable,b.evc_number,c.name,c.location,a.now_user,b.charID,a.char_u,a.char_i,a.char_p,a.char_now_hour,a.char_now_minute,a.s_key_link
            from char_state_now a
            left join ev_char b
            on b.key_link = a.key_link
            left join ev_plant c
            on c.id = b.ev_plant_id
            where {$condition_str} {$operation}
            and c.location like '$location%'
            limit $nowPage,".$Page->listRows;
        }else{
            $sql1 = "select a.id,a.key_link,a.charge,a.error,a.bespeak,a.cable,b.evc_number,c.name,c.location,a.now_user,b.charID,a.char_u,a.char_i,a.char_p,a.char_now_hour,a.char_now_minute,a.s_key_link
                from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                limit $nowPage,".$Page->listRows;
            if(!empty($_GET['location_t_1'])){
                if(I('location_s_1') == 110100 || I('location_s_1') == 120100 || I('location_s_1') == 310100 || I('location_s_1') == 500100){
                    if(I('location_s_1') == I('location_t_1')-1){
                        $location = I('location_f_1').",".I('location_s_1');
                    }else{
                        $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                    }
                }else if(I('location_s_1') == I('location_t_1')-1){
                    $location = I('location_f_1').",".I('location_s_1');
                }else{
                    $location = I('location_f_1').",".I('location_s_1').",".I('location_t_1');
                }
                $sql1 = "select a.id,a.key_link,a.charge,a.error,a.bespeak,a.cable,b.evc_number,c.name,c.location,a.now_user,b.charID,a.char_u,a.char_i,a.char_p,a.char_now_hour,a.char_now_minute,a.s_key_link
                from char_state_now a
                left join ev_char b
                on a.key_link = b.key_link
                left join ev_plant c
                on c.id = b.ev_plant_id
                where {$condition_str} {$operation}
                and c.location like '$location%'
                limit $nowPage,".$Page->listRows;
            }
        }
        $charState = M()->query($sql1);
//            echo M()->getLastSql();
        //分页结束
        foreach($charState as $k=>$v){
            //当前电桩在线情况
            $onl  = D("Admin/Online")->where("key_link='".$v['key_link']."'")->find();
            if((strtotime("now")-strtotime($onl['time_last'])) >  240 && (strtotime("now")-strtotime($onl['time_last'])) <  600){//大于240秒为异常
                $charState[$k]['status'] = 2;//异常;
            }else if((strtotime("now")-strtotime($onl['time_last'])) > 3600){//大于60分钟为下线
                $charState[$k]['status']  = 1;//下线;
                if(!empty($onl)){
                    $charState[$k]['outline'] = floor((strtotime("now")-strtotime($onl['time_last'])) / 86400);
                }else{
                    $charState[$k]['outline'] = 0;
                }
            }else if((strtotime("now")-strtotime($onl['time_last'])) < 240){
                $charState[$k]['status'] = 3;//在线;
            }
            $region    = strsToArray($v['location']);
            $regionOne = D("Admin/Region")->where("code='".$region[2]."'")->field("fullname")->find();
            $charState[$k]['location'] = $regionOne['fullname'];
            if(mb_strlen($v['name'],'utf-8') <= 12){
                $charState[$k]['name_text'] = $v['name'];
            }else{
                $charState[$k]['name_text'] = mb_substr($v['name'],0,12,"utf-8")."···";
            }
            //24小时状态颜色改变
            $c['key_link']    = $v['key_link'];
            $c['currentTime'] = date("Y-m-d",time()-86400);
            $colors = M("heart_total")->where($c)->find();
            if($colors['zero'] >= 150 && $colors['one'] >= 150 && $colors['two'] >= 150 && $colors['three'] >= 150 && $colors['four'] >= 150 && $colors['five'] >= 150 && $colors['six'] >= 150 && $colors['seven'] >= 150 && $colors['eight'] >= 150 && $colors['nine'] >= 150 && $colors['ten'] >= 150 && $colors['eleven'] >= 150 && $colors['thirteen'] >= 150 && $colors['fourteen'] >= 150 && $colors['fifteen'] >= 150 && $colors['sixteen'] >= 150 && $colors['seventeen'] >= 150 && $colors['eiighteen'] >= 150 && $colors['nineteen'] >= 150 && $colors['twenty'] >= 150 && $colors['twenty_one'] >= 150 && $colors['twenty_two'] >= 150 && $colors['twenty_three'] >= 150 && $colors['twenty_four'] >= 150 && $colors['twenty_five'] >= 150 && $colors['twenty_six'] >= 150 && $colors['twenty_seven'] >= 150 && $colors['twenty_eight'] >= 150 && $colors['twenty_nine'] >= 150 && $colors['thirty'] >= 150 && $colors['thirty_one'] >= 150 && $colors['thirty_two'] >= 150 && $colors['thirty_three'] >= 150 && $colors['thirty_four'] >= 150 && $colors['thirty_five'] >= 150 && $colors['thirty_six'] >= 150 && $colors['thirty_seven'] >= 150 && $colors['thirty_eight'] >= 150 && $colors['thirty_nine'] >= 150 && $colors['forty'] >= 150 && $colors['forty_one'] >= 150 && $colors['forty_two'] >= 150 && $colors['forty_three'] >= 150 && $colors['forty_four'] >= 150 && $colors['forty_five'] >= 150 && $colors['forty_six'] >= 150 && $colors['forty_seven'] >= 150 && $colors['twelve'] >= 150 ){
                $charState[$k]['colors'] = "btn-success";
            }elseif($colors['zero'] < 150 && $colors['zero'] >= 1 || $colors['one'] < 150 && $colors['one'] >= 1 || $colors['two'] < 150 && $colors['two'] >= 1 || $colors['three'] < 150 && $colors['three'] >= 1 || $colors['four'] < 150 && $colors['four'] >= 1 || $colors['five'] < 150 && $colors['five'] >= 1 || $colors['six'] < 150 && $colors['six'] >= 1 || $colors['seven'] < 150 && $colors['seven'] >= 1 || $colors['eight'] < 150 && $colors['eight'] >= 1 || $colors['nine'] < 150 && $colors['nine'] >= 1 || $colors['ten'] < 150 && $colors['ten'] >= 1 || $colors['eleven'] < 150 && $colors['eleven'] >= 1 || $colors['twelve'] < 150 && $colors['twelve'] >= 1 || $colors['thirteen'] < 150 && $colors['thirteen'] >= 1 || $colors['fourteen'] < 150 && $colors['fourteen'] >= 1 || $colors['fifteen'] < 150 && $colors['fifteen'] >= 1 || $colors['sixteen'] < 150 && $colors['sixteen'] >= 1 || $colors['seventeen'] < 150 && $colors['seventeen'] >= 1 || $colors['eiighteen'] < 150 && $colors['eiighteen'] >= 1 || $colors['nineteen'] < 150 && $colors['nineteen'] >= 1 || $colors['twenty'] < 150 && $colors['twenty'] >= 1 || $colors['twenty_one'] < 150 && $colors['twenty_one'] >= 1 || $colors['twenty_two'] < 150 && $colors['twenty_two'] >= 1 || $colors['twenty_three'] < 150 && $colors['twenty_three'] >= 1 || $colors['twenty_four'] < 150 && $colors['twenty_four'] >= 1 || $colors['twenty_five'] < 150 && $colors['twenty_five'] >= 1 || $colors['twenty_six'] < 150 && $colors['twenty_six'] >= 1 || $colors['twenty_seven'] < 150 && $colors['twenty_seven'] >= 1 || $colors['twenty_eight'] < 150 && $colors['twenty_eight'] >= 1 || $colors['twenty_nine'] < 150 && $colors['twenty_nine'] >= 1 || $colors['thirty'] < 150 && $colors['thirty'] >= 1 || $colors['thirty_one'] < 150 && $colors['thirty_one'] >= 1 || $colors['thirty_two'] < 150 && $colors['thirty_two'] >= 1 || $colors['thirty_three'] < 150 && $colors['thirty_three'] >= 1 || $colors['thirty_four'] < 150 && $colors['thirty_four'] >= 1 || $colors['thirty_five'] < 150 && $colors['thirty_five'] >= 1 || $colors['thirty_six'] < 150 && $colors['thirty_six'] >= 1 || $colors['thirty_seven'] < 150 && $colors['thirty_seven'] >= 1 || $colors['thirty_eight'] < 150 && $colors['thirty_eight'] >= 1 || $colors['thirty_nine'] < 150 && $colors['thirty_nine'] >= 1 || $colors['forty'] < 150 && $colors['forty'] >= 1 || $colors['forty_one'] < 150 && $colors['forty_one'] >= 1 || $colors['forty_two'] < 150 && $colors['forty_two'] >= 1 || $colors['forty_three'] < 150 && $colors['forty_three'] >= 1 || $colors['forty_four'] < 150 && $colors['forty_four'] >= 1 || $colors['forty_five'] < 150 && $colors['forty_five'] >= 1 || $colors['forty_six'] < 150 && $colors['forty_six'] >= 1 || $colors['forty_seven'] < 150 && $colors['forty_seven'] >= 1){
                $charState[$k]['colors'] = "btn-warning";
            }else{
                $charState[$k]['colors'] = "btn-danger";
            }
        }
        $this->china   = D("Admin/Region")->getChinaArea();
//        P($charState);
        $status  = array();
        $outline = array();
        foreach ($charState as $us) {
            $status[]  = $us['status'];
            $outline[] = $us['outline'];
        }
        array_multisort($status, SORT_ASC,SORT_NUMERIC, $outline, SORT_DESC,SORT_NUMERIC,$charState);//二维数组排序
//        P($charState);
        $this->charState = $charState;
        $this->display();
    }
    //详细预览
    public function detail(){
        $stateId    = I("id");
        $states     = D("Admin/State")->Relation(true)->where("id='".$stateId."'")->find();
        $charInfo   = M("char")->where("key_link='".$states['key_link']."'")->find();
        $plantInfo  = M("plant")->where("id='".$charInfo['ev_plant_id']."'")->find();
//        $memberInfo = M("member")->where("user_pay_card=1000000000000001")->find();//此处的1000000000000001会员编号从状态表里取
        $memberInfo = $states['now_user'];
        $states['charInfo']   = $charInfo;
        $states['plantInfo']  = $plantInfo;
        $states['memberInfo']  = $memberInfo;
        $this->data = $states;
        //P($states);
        $this->display();
    }
    //删除当前状态
    public function delState(){
        if(IS_GET){
            $result = D("Admin/State")->where("id='".I('id')."'")->delete();
            if($result){
                echo 1;
            }else{
                echo 0;
            }
        }else{
            $ids = strsToArray(I("ids"));
            $map['id'] = array("IN",$ids);
            $results = D("Admin/State")->where($map)->delete();
            if($results){
                $return['state'] = 100;
                $return['msg']   = '删除成功！';
            }else{
                $return['state'] = 200;
                $return['msg']   = '删除失败！';
            }
            echo json_encode($return);
            exit;
        }
    }
    //过去24小时心跳记录
    public function showState(){
        $map['key_link']    = $_GET['key_link'];
        $map['currentTime'] = date("Y-m-d",time()-86400);
        $heart = M("heart_total")->where($map)->find();
        if($heart['zero'] >= 150){
            $variable = "btn-success";
        }else if($heart['zero'] < 150 && $heart['zero'] >= 1){
            $variable = "btn-warning";
        }else if($heart['zero'] < 1){
            $variable = "btn-danger";
        }
        if($heart['one'] >= 150){
            $variable1 = "btn-success";
        }else if($heart['one'] < 150 && $heart['one'] >= 1){
            $variable1 = "btn-warning";
        }else if($heart['one'] < 1){
            $variable1 = "btn-danger";
        }
        if($heart['two'] >= 150){
            $variable2 = "btn-success";
        }else if($heart['two'] < 150 && $heart['two'] >= 1){
            $variable2 = "btn-warning";
        }else if($heart['two'] < 1){
            $variable2 = "btn-danger";
        }
        if($heart['three'] >= 150){
            $variable3 = "btn-success";
        }else if($heart['three'] < 150 && $heart['three'] >= 1){
            $variable3 = "btn-warning";
        }else if($heart['three'] < 1){
            $variable3 = "btn-danger";
        }
        if($heart['four'] >= 150){
            $variable4 = "btn-success";
        }else if($heart['four'] < 150 && $heart['four'] >= 1){
            $variable4 = "btn-warning";
        }else if($heart['four'] < 1){
            $variable4 = "btn-danger";
        }
        if($heart['five'] >= 150){
            $variable5 = "btn-success";
        }else if($heart['five'] < 150 && $heart['five'] >= 1){
            $variable5 = "btn-warning";
        }else if($heart['five'] < 1){
            $variable5 = "btn-danger";
        }
        if($heart['six'] >= 150){
            $variable6 = "btn-success";
        }else if($heart['six'] < 150 && $heart['six'] >= 1){
            $variable6 = "btn-warning";
        }else if($heart['six'] < 1){
            $variable6 = "btn-danger";
        }
        if($heart['seven'] >= 150){
            $variable7 = "btn-success";
        }else if($heart['seven'] < 150 && $heart['seven'] >= 1){
            $variable7 = "btn-warning";
        }else if($heart['seven'] < 1){
            $variable7 = "btn-danger";
        }
        if($heart['eight'] >= 150){
            $variable8 = "btn-success";
        }else if($heart['eight'] < 150 && $heart['eight'] >= 1){
            $variable8 = "btn-warning";
        }else if($heart['eight'] < 1){
            $variable8 = "btn-danger";
        }
        if($heart['nine'] >= 150){
            $variable9 = "btn-success";
        }else if($heart['nine'] < 150 && $heart['nine'] >= 1){
            $variable9 = "btn-warning";
        }else if($heart['nine'] < 1){
            $variable9 = "btn-danger";
        }
        if($heart['ten'] >= 150){
            $variable10 = "btn-success";
        }else if($heart['ten'] < 150 && $heart['ten'] >= 1){
            $variable10 = "btn-warning";
        }else if($heart['ten'] < 1){
            $variable10 = "btn-danger";
        }
        if($heart['eleven'] >= 150){
            $variable11 = "btn-success";
        }else if($heart['eleven'] < 150 && $heart['eleven'] >= 1){
            $variable11 = "btn-warning";
        }else if($heart['eleven'] < 1){
            $variable11 = "btn-danger";
        }
        if($heart['twelve'] >= 150){
            $variable12 = "btn-success";
        }else if($heart['twelve'] < 150 && $heart['twelve'] >= 1){
            $variable12 = "btn-warning";
        }else if($heart['twelve'] < 1){
            $variable12 = "btn-danger";
        }
        if($heart['thirteen'] >= 150){
            $variable13 = "btn-success";
        }else if($heart['thirteen'] < 150 && $heart['thirteen'] >= 1){
            $variable13 = "btn-warning";
        }else if($heart['thirteen'] < 1){
            $variable13 = "btn-danger";
        }
        if($heart['fourteen'] >= 150){
            $variable14 = "btn-success";
        }else if($heart['fourteen'] < 150 && $heart['fourteen'] >= 1){
            $variable14 = "btn-warning";
        }else if($heart['fourteen'] < 1){
            $variable14 = "btn-danger";
        }
        if($heart['fifteen'] >= 150){
            $variable15 = "btn-success";
        }else if($heart['fifteen'] < 150 && $heart['fifteen'] >= 1){
            $variable15 = "btn-warning";
        }else if($heart['fifteen'] < 1){
            $variable15 = "btn-danger";
        }
        if($heart['sixteen'] >= 150){
            $variable16 = "btn-success";
        }else if($heart['sixteen'] < 150 && $heart['sixteen'] >= 1){
            $variable16 = "btn-warning";
        }else if($heart['sixteen'] < 1){
            $variable16 = "btn-danger";
        }
        if($heart['seventeen'] >= 150){
            $variable17 = "btn-success";
        }else if($heart['seventeen'] < 150 && $heart['seventeen'] >= 1){
            $variable17 = "btn-warning";
        }else if($heart['seventeen'] < 1){
            $variable17 = "btn-danger";
        }
        if($heart['eiighteen'] >= 150){
            $variable18 = "btn-success";
        }else if($heart['eiighteen'] < 150 && $heart['eiighteen'] >= 1){
            $variable18 = "btn-warning";
        }else if($heart['eiighteen'] < 1){
            $variable18 = "btn-danger";
        }
        if($heart['nineteen'] >= 150){
            $variable19 = "btn-success";
        }else if($heart['nineteen'] < 150 && $heart['nineteen'] >= 1){
            $variable19 = "btn-warning";
        }else if($heart['nineteen'] < 1){
            $variable19 = "btn-danger";
        }
        if($heart['twenty'] >= 150){
            $variable20 = "btn-success";
        }else if($heart['twenty'] < 150 && $heart['twenty'] >= 1){
            $variable20 = "btn-warning";
        }else if($heart['twenty'] < 1){
            $variable20 = "btn-danger";
        }
        if($heart['twenty_one'] >= 150){
            $variable21 = "btn-success";
        }else if($heart['twenty_one'] < 150 && $heart['twenty_one'] >= 1){
            $variable21 = "btn-warning";
        }else if($heart['twenty_one'] < 1){
            $variable21 = "btn-danger";
        }
        if($heart['twenty_two'] >= 150){
            $variable22 = "btn-success";
        }else if($heart['twenty_two'] < 150 && $heart['twenty_two'] >= 1){
            $variable22 = "btn-warning";
        }else if($heart['twenty_two'] < 1){
            $variable22 = "btn-danger";
        }
        if($heart['twenty_three'] >= 150){
            $variable23 = "btn-success";
        }else if($heart['twenty_three'] < 150 && $heart['twenty_three'] >= 1){
            $variable23 = "btn-warning";
        }else if($heart['twenty_three'] < 1){
            $variable23 = "btn-danger";
        }
        if($heart['twenty_four'] >= 150){
            $variable24 = "btn-success";
        }else if($heart['twenty_four'] < 150 && $heart['twenty_four'] >= 1){
            $variable24 = "btn-warning";
        }else if($heart['twenty_four'] < 1){
            $variable24 = "btn-danger";
        }
        if($heart['twenty_five'] >= 150){
            $variable25 = "btn-success";
        }else if($heart['twenty_five'] < 150 && $heart['twenty_five'] >= 1){
            $variable25 = "btn-warning";
        }else if($heart['twenty_five'] < 1){
            $variable25 = "btn-danger";
        }
        if($heart['twenty_six'] >= 150){
            $variable26 = "btn-success";
        }else if($heart['twenty_six'] < 150 && $heart['twenty_six'] >= 1){
            $variable26 = "btn-warning";
        }else if($heart['twenty_six'] < 1){
            $variable26 = "btn-danger";
        }
        if($heart['twenty_seven'] >= 150){
            $variable27 = "btn-success";
        }else if($heart['twenty_seven'] < 150 && $heart['twenty_seven'] >= 1){
            $variable27 = "btn-warning";
        }else if($heart['twenty_seven'] < 1){
            $variable27 = "btn-danger";
        }
        if($heart['twenty_eight'] >= 150){
            $variable28 = "btn-success";
        }else if($heart['twenty_eight'] < 150 && $heart['twenty_eight'] >= 1){
            $variable28 = "btn-warning";
        }else if($heart['twenty_eight'] < 1){
            $variable28 = "btn-danger";
        }
        if($heart['twenty_nine'] >= 150){
            $variable29 = "btn-success";
        }else if($heart['twenty_nine'] < 150 && $heart['twenty_nine'] >= 1){
            $variable29 = "btn-warning";
        }else if($heart['twenty_nine'] < 1){
            $variable29 = "btn-danger";
        }
        if($heart['thirty'] >= 150){
            $variable30 = "btn-success";
        }else if($heart['thirty'] < 150 && $heart['thirty'] >= 1){
            $variable30 = "btn-warning";
        }else if($heart['thirty'] < 1){
            $variable30 = "btn-danger";
        }
        if($heart['thirty_one'] >= 150){
            $variable31 = "btn-success";
        }else if($heart['thirty_one'] < 150 && $heart['thirty_one'] >= 1){
            $variable31 = "btn-warning";
        }else if($heart['thirty_one'] < 1){
            $variable31 = "btn-danger";
        }
        if($heart['thirty_two'] >= 150){
            $variable32 = "btn-success";
        }else if($heart['thirty_two'] < 150 && $heart['thirty_two'] >= 1){
            $variable32 = "btn-warning";
        }else if($heart['thirty_two'] < 1){
            $variable32 = "btn-danger";
        }
        if($heart['thirty_three'] >= 150){
            $variable33 = "btn-success";
        }else if($heart['thirty_three'] < 150 && $heart['thirty_three'] >= 1){
            $variable33 = "btn-warning";
        }else if($heart['thirty_three'] < 1){
            $variable33 = "btn-danger";
        }
        if($heart['thirty_four'] >= 150){
            $variable34 = "btn-success";
        }else if($heart['thirty_four'] < 150 && $heart['thirty_four'] >= 1){
            $variable34 = "btn-warning";
        }else if($heart['thirty_four'] < 1){
            $variable34 = "btn-danger";
        }
        if($heart['thirty_five'] >= 150){
            $variable35 = "btn-success";
        }else if($heart['thirty_five'] < 150 && $heart['thirty_five'] >= 1){
            $variable35 = "btn-warning";
        }else if($heart['thirty_five'] < 1){
            $variable35 = "btn-danger";
        }
        if($heart['thirty_six'] >= 150){
            $variable36 = "btn-success";
        }else if($heart['thirty_six'] < 150 && $heart['thirty_six'] >= 1){
            $variable36 = "btn-warning";
        }else if($heart['thirty_six'] < 1){
            $variable36 = "btn-danger";
        }
        if($heart['thirty_seven'] >= 150){
            $variable37 = "btn-success";
        }else if($heart['thirty_seven'] < 150 && $heart['thirty_seven'] >= 1){
            $variable37 = "btn-warning";
        }else if($heart['thirty_seven'] < 1){
            $variable37 = "btn-danger";
        }
        if($heart['thirty_eight'] >= 150){
            $variable38 = "btn-success";
        }else if($heart['thirty_eight'] < 150 && $heart['thirty_eight'] >= 1){
            $variable38 = "btn-warning";
        }else if($heart['thirty_eight'] < 1){
            $variable38 = "btn-danger";
        }
        if($heart['thirty_nine'] >= 150){
            $variable39 = "btn-success";
        }else if($heart['thirty_nine'] < 150 && $heart['thirty_nine'] >= 1){
            $variable39 = "btn-warning";
        }else if($heart['thirty_nine'] < 1){
            $variable39 = "btn-danger";
        }
        if($heart['forty'] >= 150){
            $variable40 = "btn-success";
        }else if($heart['forty'] < 150 && $heart['forty'] >= 1){
            $variable40 = "btn-warning";
        }else if($heart['forty'] < 1){
            $variable40 = "btn-danger";
        }
        if($heart['forty_one'] >= 150){
            $variable41 = "btn-success";
        }else if($heart['forty_one'] < 150 && $heart['forty_one'] >= 1){
            $variable41 = "btn-warning";
        }else if($heart['forty_one'] < 1){
            $variable41 = "btn-danger";
        }
        if($heart['forty_two'] >= 150){
            $variable42 = "btn-success";
        }else if($heart['forty_two'] < 150 && $heart['forty_two'] >= 1){
            $variable42 = "btn-warning";
        }else if($heart['forty_two'] < 1){
            $variable42 = "btn-danger";
        }
        if($heart['forty_three'] >= 150){
            $variable43 = "btn-success";
        }else if($heart['forty_three'] < 150 && $heart['forty_three'] >= 1){
            $variable43 = "btn-warning";
        }else if($heart['forty_three'] < 1){
            $variable43 = "btn-danger";
        }
        if($heart['forty_four'] >= 150){
            $variable44 = "btn-success";
        }else if($heart['forty_four'] < 150 && $heart['forty_four'] >= 1){
            $variable44 = "btn-warning";
        }else if($heart['forty_four'] < 1){
            $variable44 = "btn-danger";
        }
        if($heart['forty_five'] >= 150){
            $variable45 = "btn-success";
        }else if($heart['forty_five'] < 150 && $heart['forty_five'] >= 1){
            $variable45 = "btn-warning";
        }else if($heart['forty_five'] < 1){
            $variable45 = "btn-danger";
        }
        if($heart['forty_six'] >= 150){
            $variable46 = "btn-success";
        }else if($heart['forty_six'] < 150 && $heart['forty_six'] >= 1){
            $variable46 = "btn-warning";
        }else if($heart['forty_six'] < 1){
            $variable46 = "btn-danger";
        }
        if($heart['forty_seven'] >= 150){
            $variable47 = "btn-success";
        }else if($heart['forty_seven'] < 150 && $heart['forty_seven'] >= 1){
            $variable47 = "btn-warning";
        }else if($heart['forty_seven'] < 1){
            $variable47 = "btn-danger";
        }

        $str = '<p>'.$heart["currentTime"].'</p>
                <input type="hidden" class="keylink" value="'.$_GET['key_link'].'">
                <button type="button" class="btn btn-sm '.$variable.'">00:00<br/>'.$heart["zero"].'</button>
                <button type="button" class="btn btn-sm '.$variable1.'">00:30<br/>'.$heart["one"].'</button>
                <button type="button" class="btn btn-sm '.$variable2.'">01:00<br/>'.$heart["two"].'</button>
                <button type="button" class="btn btn-sm '.$variable3.'">01:30<br/>'.$heart["three"].'</button>
                <button type="button" class="btn btn-sm '.$variable4.'">02:00<br/>'.$heart["four"].'</button>
                <button type="button" class="btn btn-sm '.$variable5.'">02:30<br/>'.$heart["five"].'</button>
                <button type="button" class="btn btn-sm '.$variable6.'">03:00<br/>'.$heart["six"].'</button>
                <button type="button" class="btn btn-sm '.$variable7.'">03:30<br/>'.$heart["seven"].'</button><br/><br/>
                <button type="button" class="btn btn-sm '.$variable8.'">04:00<br/>'.$heart["eight"].'</button>
                <button type="button" class="btn btn-sm '.$variable9.'">04:30<br/>'.$heart["nine"].'</button>
                <button type="button" class="btn btn-sm '.$variable10.'">05:00<br/>'.$heart["ten"].'</button>
                <button type="button" class="btn btn-sm '.$variable11.'">05:30<br/>'.$heart["eleven"].'</button>
                <button type="button" class="btn btn-sm '.$variable12.'">06:00<br/>'.$heart["twelve"].'</button>
                <button type="button" class="btn btn-sm '.$variable13.'">06:30<br/>'.$heart["thirteen"].'</button>
                <button type="button" class="btn btn-sm '.$variable14.'">07:00<br/>'.$heart["fourteen"].'</button>
                <button type="button" class="btn btn-sm '.$variable15.'">07:30<br/>'.$heart["fifteen"].'</button><br/><br/>
                <button type="button" class="btn btn-sm '.$variable16.'">08:00<br/>'.$heart["sixteen"].'</button>
                <button type="button" class="btn btn-sm '.$variable17.'">08:30<br/>'.$heart["seventeen"].'</button>
                <button type="button" class="btn btn-sm '.$variable18.'">09:00<br/>'.$heart["eiighteen"].'</button>
                <button type="button" class="btn btn-sm '.$variable19.'">09:30<br/>'.$heart["nineteen"].'</button>
                <button type="button" class="btn btn-sm '.$variable20.'">10:00<br/>'.$heart["twenty"].'</button>
                <button type="button" class="btn btn-sm '.$variable21.'">10:30<br/>'.$heart["twenty_one"].'</button>
                <button type="button" class="btn btn-sm '.$variable22.'">11:00<br/>'.$heart["twenty_two"].'</button>
                <button type="button" class="btn btn-sm '.$variable23.'">11:30<br/>'.$heart["twenty_three"].'</button><br/><br/>
                <button type="button" class="btn btn-sm '.$variable24.'">12:00<br/>'.$heart["twenty_four"].'</button>
                <button type="button" class="btn btn-sm '.$variable25.'">12:30<br/>'.$heart["twenty_five"].'</button>
                <button type="button" class="btn btn-sm '.$variable26.'">13:00<br/>'.$heart["twenty_six"].'</button>
                <button type="button" class="btn btn-sm '.$variable27.'">13:30<br/>'.$heart["twenty_seven"].'</button>
                <button type="button" class="btn btn-sm '.$variable28.'">14:00<br/>'.$heart["twenty_eight"].'</button>
                <button type="button" class="btn btn-sm '.$variable29.'">14:30<br/>'.$heart["twenty_nine"].'</button>
                <button type="button" class="btn btn-sm '.$variable30.'">15:00<br/>'.$heart["thirty"].'</button>
                <button type="button" class="btn btn-sm '.$variable31.'">15:30<br/>'.$heart["thirty_one"].'</button><br/><br/>
                <button type="button" class="btn btn-sm '.$variable32.'">16:00<br/>'.$heart["thirty_two"].'</button>
                <button type="button" class="btn btn-sm '.$variable33.'">16:30<br/>'.$heart["thirty_three"].'</button>
                <button type="button" class="btn btn-sm '.$variable34.'">17:00<br/>'.$heart["thirty_four"].'</button>
                <button type="button" class="btn btn-sm '.$variable35.'">17:30<br/>'.$heart["thirty_five"].'</button>
                <button type="button" class="btn btn-sm '.$variable36.'">18:00<br/>'.$heart["thirty_six"].'</button>
                <button type="button" class="btn btn-sm '.$variable37.'">18:30<br/>'.$heart["thirty_seven"].'</button>
                <button type="button" class="btn btn-sm '.$variable38.'">19:00<br/>'.$heart["thirty_eight"].'</button>
                <button type="button" class="btn btn-sm '.$variable39.'">19:30<br/>'.$heart["thirty_nine"].'</button><br/><br/>
                <button type="button" class="btn btn-sm '.$variable40.'">20:00<br/>'.$heart["forty"].'</button>
                <button type="button" class="btn btn-sm '.$variable41.'">20:30<br/>'.$heart["forty_one"].'</button>
                <button type="button" class="btn btn-sm '.$variable42.'">21:00<br/>'.$heart["forty_two"].'</button>
                <button type="button" class="btn btn-sm '.$variable43.'">21:30<br/>'.$heart["forty_three"].'</button>
                <button type="button" class="btn btn-sm '.$variable44.'">22:00<br/>'.$heart["forty_four"].'</button>
                <button type="button" class="btn btn-sm '.$variable45.'">22:30<br/>'.$heart["forty_five"].'</button>
                <button type="button" class="btn btn-sm '.$variable46.'">23:00<br/>'.$heart["forty_six"].'</button>
                <button type="button" class="btn btn-sm '.$variable47.'">23:30<br/>'.$heart["forty_seven"].'</button>
        ';
        echo $str;
        exit;
    }

    //当前时间前的每小时心跳记录数
    public function todayState(){
        $key_link   = $_GET['key_link'];
        $tot        = date("Y-m-d 00:00:00",time());//今天开始时间
        $tom        = date("Y-m-d 00:00:00",time() + 86400);//明天开始时间
        $model      = M();
        $str        = "";
        $sql        = "SELECT date_format( time, '%Y-%m-%d %H ' ) AS time, count( * ) AS total
                        FROM char_heart_record
                        where key_link = '$key_link'
                        and time >= '$tot'
                        and time < '$tom'
                        GROUP BY date_format( time, '%Y-%m-%d %H ' )";
        $todays = $model->query($sql);
        foreach($todays as $k => $v){

            if($v['total'] >= 50){
                $variable = "btn-success";
            }else if($v['total'] < 50 && $v['total'] >= 1){
                $variable = "btn-warning";
            }else if($v['total'] < 1){
                $variable = "btn-danger";
            }
            $str .= '<button type="button" style="margin-left: 6px;margin-bottom: 10px" class="btn btn-sm '.$variable.'">'.str_pad($k,2,0,STR_PAD_LEFT).':00<br/>'.$v["total"].'</button>
                    ';
        }
        echo $str;
        exit;
    }

    //历史心跳记录
    public function search_heart(){
        $key_link   = $_GET["key_link"];
        $start_time = $_GET["start_time"];
        $end_time   =  $_GET["end_time"];
        $str        = '';
        if($end_time != '' && $start_time != ''){
            $map['key_link']    = $key_link;
            $map['currentTime'] = array(array('EGT',$start_time),array('ELT',$end_time));
            $hearts = M("heart_total")->where($map)->select();
            foreach($hearts as $heart){
                if($heart['zero'] >= 150){
                    $variable = "btn-success";
                }else if($heart['zero'] < 150 && $heart['zero'] >= 1){
                    $variable = "btn-warning";
                }else if($heart['zero'] < 1){
                    $variable = "btn-danger";
                }
                if($heart['one'] >= 150){
                    $variable1 = "btn-success";
                }else if($heart['one'] < 150 && $heart['one'] >= 1){
                    $variable1 = "btn-warning";
                }else if($heart['one'] < 1){
                    $variable1 = "btn-danger";
                }
                if($heart['two'] >= 150){
                    $variable2 = "btn-success";
                }else if($heart['two'] < 150 && $heart['two'] >= 1){
                    $variable2 = "btn-warning";
                }else if($heart['two'] < 1){
                    $variable2 = "btn-danger";
                }
                if($heart['three'] >= 150){
                    $variable3 = "btn-success";
                }else if($heart['three'] < 150 && $heart['three'] >= 1){
                    $variable3 = "btn-warning";
                }else if($heart['three'] < 1){
                    $variable3 = "btn-danger";
                }
                if($heart['four'] >= 150){
                    $variable4 = "btn-success";
                }else if($heart['four'] < 150 && $heart['four'] >= 1){
                    $variable4 = "btn-warning";
                }else if($heart['four'] < 1){
                    $variable4 = "btn-danger";
                }
                if($heart['five'] >= 150){
                    $variable5 = "btn-success";
                }else if($heart['five'] < 150 && $heart['five'] >= 1){
                    $variable5 = "btn-warning";
                }else if($heart['five'] < 1){
                    $variable5 = "btn-danger";
                }
                if($heart['six'] >= 150){
                    $variable6 = "btn-success";
                }else if($heart['six'] < 150 && $heart['six'] >= 1){
                    $variable6 = "btn-warning";
                }else if($heart['six'] < 1){
                    $variable6 = "btn-danger";
                }
                if($heart['seven'] >= 150){
                    $variable7 = "btn-success";
                }else if($heart['seven'] < 150 && $heart['seven'] >= 1){
                    $variable7 = "btn-warning";
                }else if($heart['seven'] < 1){
                    $variable7 = "btn-danger";
                }
                if($heart['eight'] >= 150){
                    $variable8 = "btn-success";
                }else if($heart['eight'] < 150 && $heart['eight'] >= 1){
                    $variable8 = "btn-warning";
                }else if($heart['eight'] < 1){
                    $variable8 = "btn-danger";
                }
                if($heart['nine'] >= 150){
                    $variable9 = "btn-success";
                }else if($heart['nine'] < 150 && $heart['nine'] >= 1){
                    $variable9 = "btn-warning";
                }else if($heart['nine'] < 1){
                    $variable9 = "btn-danger";
                }
                if($heart['ten'] >= 150){
                    $variable10 = "btn-success";
                }else if($heart['ten'] < 150 && $heart['ten'] >= 1){
                    $variable10 = "btn-warning";
                }else if($heart['ten'] < 1){
                    $variable10 = "btn-danger";
                }
                if($heart['eleven'] >= 150){
                    $variable11 = "btn-success";
                }else if($heart['eleven'] < 150 && $heart['eleven'] >= 1){
                    $variable11 = "btn-warning";
                }else if($heart['eleven'] < 1){
                    $variable11 = "btn-danger";
                }
                if($heart['twelve'] >= 150){
                    $variable12 = "btn-success";
                }else if($heart['twelve'] < 150 && $heart['twelve'] >= 1){
                    $variable12 = "btn-warning";
                }else if($heart['twelve'] < 1){
                    $variable12 = "btn-danger";
                }
                if($heart['thirteen'] >= 150){
                    $variable13 = "btn-success";
                }else if($heart['thirteen'] < 150 && $heart['thirteen'] >= 1){
                    $variable13 = "btn-warning";
                }else if($heart['thirteen'] < 1){
                    $variable13 = "btn-danger";
                }
                if($heart['fourteen'] >= 150){
                    $variable14 = "btn-success";
                }else if($heart['fourteen'] < 150 && $heart['fourteen'] >= 1){
                    $variable14 = "btn-warning";
                }else if($heart['fourteen'] < 1){
                    $variable14 = "btn-danger";
                }
                if($heart['fifteen'] >= 150){
                    $variable15 = "btn-success";
                }else if($heart['fifteen'] < 150 && $heart['fifteen'] >= 1){
                    $variable15 = "btn-warning";
                }else if($heart['fifteen'] < 1){
                    $variable15 = "btn-danger";
                }
                if($heart['sixteen'] >= 150){
                    $variable16 = "btn-success";
                }else if($heart['sixteen'] < 150 && $heart['sixteen'] >= 1){
                    $variable16 = "btn-warning";
                }else if($heart['sixteen'] < 1){
                    $variable16 = "btn-danger";
                }
                if($heart['seventeen'] >= 150){
                    $variable17 = "btn-success";
                }else if($heart['seventeen'] < 150 && $heart['seventeen'] >= 1){
                    $variable17 = "btn-warning";
                }else if($heart['seventeen'] < 1){
                    $variable17 = "btn-danger";
                }
                if($heart['eiighteen'] >= 150){
                    $variable18 = "btn-success";
                }else if($heart['eiighteen'] < 150 && $heart['eiighteen'] >= 1){
                    $variable18 = "btn-warning";
                }else if($heart['eiighteen'] < 1){
                    $variable18 = "btn-danger";
                }
                if($heart['nineteen'] >= 150){
                    $variable19 = "btn-success";
                }else if($heart['nineteen'] < 150 && $heart['nineteen'] >= 1){
                    $variable19 = "btn-warning";
                }else if($heart['nineteen'] < 1){
                    $variable19 = "btn-danger";
                }
                if($heart['twenty'] >= 150){
                    $variable20 = "btn-success";
                }else if($heart['twenty'] < 150 && $heart['twenty'] >= 1){
                    $variable20 = "btn-warning";
                }else if($heart['twenty'] < 1){
                    $variable20 = "btn-danger";
                }
                if($heart['twenty_one'] >= 150){
                    $variable21 = "btn-success";
                }else if($heart['twenty_one'] < 150 && $heart['twenty_one'] >= 1){
                    $variable21 = "btn-warning";
                }else if($heart['twenty_one'] < 1){
                    $variable21 = "btn-danger";
                }
                if($heart['twenty_two'] >= 150){
                    $variable22 = "btn-success";
                }else if($heart['twenty_two'] < 150 && $heart['twenty_two'] >= 1){
                    $variable22 = "btn-warning";
                }else if($heart['twenty_two'] < 1){
                    $variable22 = "btn-danger";
                }
                if($heart['twenty_three'] >= 150){
                    $variable23 = "btn-success";
                }else if($heart['twenty_three'] < 150 && $heart['twenty_three'] >= 1){
                    $variable23 = "btn-warning";
                }else if($heart['twenty_three'] < 1){
                    $variable23 = "btn-danger";
                }
                if($heart['twenty_four'] >= 150){
                    $variable24 = "btn-success";
                }else if($heart['twenty_four'] < 150 && $heart['twenty_four'] >= 1){
                    $variable24 = "btn-warning";
                }else if($heart['twenty_four'] < 1){
                    $variable24 = "btn-danger";
                }
                if($heart['twenty_five'] >= 150){
                    $variable25 = "btn-success";
                }else if($heart['twenty_five'] < 150 && $heart['twenty_five'] >= 1){
                    $variable25 = "btn-warning";
                }else if($heart['twenty_five'] < 1){
                    $variable25 = "btn-danger";
                }
                if($heart['twenty_six'] >= 150){
                    $variable26 = "btn-success";
                }else if($heart['twenty_six'] < 150 && $heart['twenty_six'] >= 1){
                    $variable26 = "btn-warning";
                }else if($heart['twenty_six'] < 1){
                    $variable26 = "btn-danger";
                }
                if($heart['twenty_seven'] >= 150){
                    $variable27 = "btn-success";
                }else if($heart['twenty_seven'] < 150 && $heart['twenty_seven'] >= 1){
                    $variable27 = "btn-warning";
                }else if($heart['twenty_seven'] < 1){
                    $variable27 = "btn-danger";
                }
                if($heart['twenty_eight'] >= 150){
                    $variable28 = "btn-success";
                }else if($heart['twenty_eight'] < 150 && $heart['twenty_eight'] >= 1){
                    $variable28 = "btn-warning";
                }else if($heart['twenty_eight'] < 1){
                    $variable28 = "btn-danger";
                }
                if($heart['twenty_nine'] >= 150){
                    $variable29 = "btn-success";
                }else if($heart['twenty_nine'] < 150 && $heart['twenty_nine'] >= 1){
                    $variable29 = "btn-warning";
                }else if($heart['twenty_nine'] < 1){
                    $variable29 = "btn-danger";
                }
                if($heart['thirty'] >= 150){
                    $variable30 = "btn-success";
                }else if($heart['thirty'] < 150 && $heart['thirty'] >= 1){
                    $variable30 = "btn-warning";
                }else if($heart['thirty'] < 1){
                    $variable30 = "btn-danger";
                }
                if($heart['thirty_one'] >= 150){
                    $variable31 = "btn-success";
                }else if($heart['thirty_one'] < 150 && $heart['thirty_one'] >= 1){
                    $variable31 = "btn-warning";
                }else if($heart['thirty_one'] < 1){
                    $variable31 = "btn-danger";
                }
                if($heart['thirty_two'] >= 150){
                    $variable32 = "btn-success";
                }else if($heart['thirty_two'] < 150 && $heart['thirty_two'] >= 1){
                    $variable32 = "btn-warning";
                }else if($heart['thirty_two'] < 1){
                    $variable32 = "btn-danger";
                }
                if($heart['thirty_three'] >= 150){
                    $variable33 = "btn-success";
                }else if($heart['thirty_three'] < 150 && $heart['thirty_three'] >= 1){
                    $variable33 = "btn-warning";
                }else if($heart['thirty_three'] < 1){
                    $variable33 = "btn-danger";
                }
                if($heart['thirty_four'] >= 150){
                    $variable34 = "btn-success";
                }else if($heart['thirty_four'] < 150 && $heart['thirty_four'] >= 1){
                    $variable34 = "btn-warning";
                }else if($heart['thirty_four'] < 1){
                    $variable34 = "btn-danger";
                }
                if($heart['thirty_five'] >= 150){
                    $variable35 = "btn-success";
                }else if($heart['thirty_five'] < 150 && $heart['thirty_five'] >= 1){
                    $variable35 = "btn-warning";
                }else if($heart['thirty_five'] < 1){
                    $variable35 = "btn-danger";
                }
                if($heart['thirty_six'] >= 150){
                    $variable36 = "btn-success";
                }else if($heart['thirty_six'] < 150 && $heart['thirty_six'] >= 1){
                    $variable36 = "btn-warning";
                }else if($heart['thirty_six'] < 1){
                    $variable36 = "btn-danger";
                }
                if($heart['thirty_seven'] >= 150){
                    $variable37 = "btn-success";
                }else if($heart['thirty_seven'] < 150 && $heart['thirty_seven'] >= 1){
                    $variable37 = "btn-warning";
                }else if($heart['thirty_seven'] < 1){
                    $variable37 = "btn-danger";
                }
                if($heart['thirty_eight'] >= 150){
                    $variable38 = "btn-success";
                }else if($heart['thirty_eight'] < 150 && $heart['thirty_eight'] >= 1){
                    $variable38 = "btn-warning";
                }else if($heart['thirty_eight'] < 1){
                    $variable38 = "btn-danger";
                }
                if($heart['thirty_nine'] >= 150){
                    $variable39 = "btn-success";
                }else if($heart['thirty_nine'] < 150 && $heart['thirty_nine'] >= 1){
                    $variable39 = "btn-warning";
                }else if($heart['thirty_nine'] < 1){
                    $variable39 = "btn-danger";
                }
                if($heart['forty'] >= 150){
                    $variable40 = "btn-success";
                }else if($heart['forty'] < 150 && $heart['forty'] >= 1){
                    $variable40 = "btn-warning";
                }else if($heart['forty'] < 1){
                    $variable40 = "btn-danger";
                }
                if($heart['forty_one'] >= 150){
                    $variable41 = "btn-success";
                }else if($heart['forty_one'] < 150 && $heart['forty_one'] >= 1){
                    $variable41 = "btn-warning";
                }else if($heart['forty_one'] < 1){
                    $variable41 = "btn-danger";
                }
                if($heart['forty_two'] >= 150){
                    $variable42 = "btn-success";
                }else if($heart['forty_two'] < 150 && $heart['forty_two'] >= 1){
                    $variable42 = "btn-warning";
                }else if($heart['forty_two'] < 1){
                    $variable42 = "btn-danger";
                }
                if($heart['forty_three'] >= 150){
                    $variable43 = "btn-success";
                }else if($heart['forty_three'] < 150 && $heart['forty_three'] >= 1){
                    $variable43 = "btn-warning";
                }else if($heart['forty_three'] < 1){
                    $variable43 = "btn-danger";
                }
                if($heart['forty_four'] >= 150){
                    $variable44 = "btn-success";
                }else if($heart['forty_four'] < 150 && $heart['forty_four'] >= 1){
                    $variable44 = "btn-warning";
                }else if($heart['forty_four'] < 1){
                    $variable44 = "btn-danger";
                }
                if($heart['forty_five'] >= 150){
                    $variable45 = "btn-success";
                }else if($heart['forty_five'] < 150 && $heart['forty_five'] >= 1){
                    $variable45 = "btn-warning";
                }else if($heart['forty_five'] < 1){
                    $variable45 = "btn-danger";
                }
                if($heart['forty_six'] >= 150){
                    $variable46 = "btn-success";
                }else if($heart['forty_six'] < 150 && $heart['forty_six'] >= 1){
                    $variable46 = "btn-warning";
                }else if($heart['forty_six'] < 1){
                    $variable46 = "btn-danger";
                }
                if($heart['forty_seven'] >= 150){
                    $variable47 = "btn-success";
                }else if($heart['forty_seven'] < 150 && $heart['forty_seven'] >= 1){
                    $variable47 = "btn-warning";
                }else if($heart['forty_seven'] < 1){
                    $variable47 = "btn-danger";
                }

                $str .= '<p>'.$heart["currentTime"].'</p>
                <button type="button" class="btn btn-sm '.$variable.'">00:00<br/>'.$heart["zero"].'</button>
                <button type="button" class="btn btn-sm '.$variable1.'">00:30<br/>'.$heart["one"].'</button>
                <button type="button" class="btn btn-sm '.$variable2.'">01:00<br/>'.$heart["two"].'</button>
                <button type="button" class="btn btn-sm '.$variable3.'">01:30<br/>'.$heart["three"].'</button>
                <button type="button" class="btn btn-sm '.$variable4.'">02:00<br/>'.$heart["four"].'</button>
                <button type="button" class="btn btn-sm '.$variable5.'">02:30<br/>'.$heart["five"].'</button>
                <button type="button" class="btn btn-sm '.$variable6.'">03:00<br/>'.$heart["six"].'</button>
                <button type="button" class="btn btn-sm '.$variable7.'">03:30<br/>'.$heart["seven"].'</button><br/><br/>
                <button type="button" class="btn btn-sm '.$variable8.'">04:00<br/>'.$heart["eight"].'</button>
                <button type="button" class="btn btn-sm '.$variable9.'">04:30<br/>'.$heart["nine"].'</button>
                <button type="button" class="btn btn-sm '.$variable10.'">05:00<br/>'.$heart["ten"].'</button>
                <button type="button" class="btn btn-sm '.$variable11.'">05:30<br/>'.$heart["eleven"].'</button>
                <button type="button" class="btn btn-sm '.$variable12.'">06:00<br/>'.$heart["twelve"].'</button>
                <button type="button" class="btn btn-sm '.$variable13.'">06:30<br/>'.$heart["thirteen"].'</button>
                <button type="button" class="btn btn-sm '.$variable14.'">07:00<br/>'.$heart["fourteen"].'</button>
                <button type="button" class="btn btn-sm '.$variable15.'">07:30<br/>'.$heart["fifteen"].'</button><br/><br/>
                <button type="button" class="btn btn-sm '.$variable16.'">08:00<br/>'.$heart["sixteen"].'</button>
                <button type="button" class="btn btn-sm '.$variable17.'">08:30<br/>'.$heart["seventeen"].'</button>
                <button type="button" class="btn btn-sm '.$variable18.'">09:00<br/>'.$heart["eiighteen"].'</button>
                <button type="button" class="btn btn-sm '.$variable19.'">09:30<br/>'.$heart["nineteen"].'</button>
                <button type="button" class="btn btn-sm '.$variable20.'">10:00<br/>'.$heart["twenty"].'</button>
                <button type="button" class="btn btn-sm '.$variable21.'">10:30<br/>'.$heart["twenty_one"].'</button>
                <button type="button" class="btn btn-sm '.$variable22.'">11:00<br/>'.$heart["twenty_two"].'</button>
                <button type="button" class="btn btn-sm '.$variable23.'">11:30<br/>'.$heart["twenty_three"].'</button><br/><br/>
                <button type="button" class="btn btn-sm '.$variable24.'">12:00<br/>'.$heart["twenty_four"].'</button>
                <button type="button" class="btn btn-sm '.$variable25.'">12:30<br/>'.$heart["twenty_five"].'</button>
                <button type="button" class="btn btn-sm '.$variable26.'">13:00<br/>'.$heart["twenty_six"].'</button>
                <button type="button" class="btn btn-sm '.$variable27.'">13:30<br/>'.$heart["twenty_seven"].'</button>
                <button type="button" class="btn btn-sm '.$variable28.'">14:00<br/>'.$heart["twenty_eight"].'</button>
                <button type="button" class="btn btn-sm '.$variable29.'">14:30<br/>'.$heart["twenty_nine"].'</button>
                <button type="button" class="btn btn-sm '.$variable30.'">15:00<br/>'.$heart["thirty"].'</button>
                <button type="button" class="btn btn-sm '.$variable31.'">15:30<br/>'.$heart["thirty_one"].'</button><br/><br/>
                <button type="button" class="btn btn-sm '.$variable32.'">16:00<br/>'.$heart["thirty_two"].'</button>
                <button type="button" class="btn btn-sm '.$variable33.'">16:30<br/>'.$heart["thirty_three"].'</button>
                <button type="button" class="btn btn-sm '.$variable34.'">17:00<br/>'.$heart["thirty_four"].'</button>
                <button type="button" class="btn btn-sm '.$variable35.'">17:30<br/>'.$heart["thirty_five"].'</button>
                <button type="button" class="btn btn-sm '.$variable36.'">18:00<br/>'.$heart["thirty_six"].'</button>
                <button type="button" class="btn btn-sm '.$variable37.'">18:30<br/>'.$heart["thirty_seven"].'</button>
                <button type="button" class="btn btn-sm '.$variable38.'">19:00<br/>'.$heart["thirty_eight"].'</button>
                <button type="button" class="btn btn-sm '.$variable39.'">19:30<br/>'.$heart["thirty_nine"].'</button><br/><br/>
                <button type="button" class="btn btn-sm '.$variable40.'">20:00<br/>'.$heart["forty"].'</button>
                <button type="button" class="btn btn-sm '.$variable41.'">20:30<br/>'.$heart["forty_one"].'</button>
                <button type="button" class="btn btn-sm '.$variable42.'">21:00<br/>'.$heart["forty_two"].'</button>
                <button type="button" class="btn btn-sm '.$variable43.'">21:30<br/>'.$heart["forty_three"].'</button>
                <button type="button" class="btn btn-sm '.$variable44.'">22:00<br/>'.$heart["forty_four"].'</button>
                <button type="button" class="btn btn-sm '.$variable45.'">22:30<br/>'.$heart["forty_five"].'</button>
                <button type="button" class="btn btn-sm '.$variable46.'">23:00<br/>'.$heart["forty_six"].'</button>
                <button type="button" class="btn btn-sm '.$variable47.'">23:30<br/>'.$heart["forty_seven"].'</button><br/><br/>
        ';
            }
        echo $str;
        exit;
        }
        if($end_time == '' && $start_time != ''){
            $map['key_link']    = $key_link;
            $map['currentTime'] = $start_time;
            $heart = M("heart_total")->where($map)->find();
            if($heart['zero'] >= 150){
                $variable = "btn-success";
            }else if($heart['zero'] < 150 && $heart['zero'] >= 1){
                $variable = "btn-warning";
            }else if($heart['zero'] < 1){
                $variable = "btn-danger";
            }
            if($heart['one'] >= 150){
                $variable1 = "btn-success";
            }else if($heart['one'] < 150 && $heart['one'] >= 1){
                $variable1 = "btn-warning";
            }else if($heart['one'] < 1){
                $variable1 = "btn-danger";
            }
            if($heart['two'] >= 150){
                $variable2 = "btn-success";
            }else if($heart['two'] < 150 && $heart['two'] >= 1){
                $variable2 = "btn-warning";
            }else if($heart['two'] < 1){
                $variable2 = "btn-danger";
            }
            if($heart['three'] >= 150){
                $variable3 = "btn-success";
            }else if($heart['three'] < 150 && $heart['three'] >= 1){
                $variable3 = "btn-warning";
            }else if($heart['three'] < 1){
                $variable3 = "btn-danger";
            }
            if($heart['four'] >= 150){
                $variable4 = "btn-success";
            }else if($heart['four'] < 150 && $heart['four'] >= 1){
                $variable4 = "btn-warning";
            }else if($heart['four'] < 1){
                $variable4 = "btn-danger";
            }
            if($heart['five'] >= 150){
                $variable5 = "btn-success";
            }else if($heart['five'] < 150 && $heart['five'] >= 1){
                $variable5 = "btn-warning";
            }else if($heart['five'] < 1){
                $variable5 = "btn-danger";
            }
            if($heart['six'] >= 150){
                $variable6 = "btn-success";
            }else if($heart['six'] < 150 && $heart['six'] >= 1){
                $variable6 = "btn-warning";
            }else if($heart['six'] < 1){
                $variable6 = "btn-danger";
            }
            if($heart['seven'] >= 150){
                $variable7 = "btn-success";
            }else if($heart['seven'] < 150 && $heart['seven'] >= 1){
                $variable7 = "btn-warning";
            }else if($heart['seven'] < 1){
                $variable7 = "btn-danger";
            }
            if($heart['eight'] >= 150){
                $variable8 = "btn-success";
            }else if($heart['eight'] < 150 && $heart['eight'] >= 1){
                $variable8 = "btn-warning";
            }else if($heart['eight'] < 1){
                $variable8 = "btn-danger";
            }
            if($heart['nine'] >= 150){
                $variable9 = "btn-success";
            }else if($heart['nine'] < 150 && $heart['nine'] >= 1){
                $variable9 = "btn-warning";
            }else if($heart['nine'] < 1){
                $variable9 = "btn-danger";
            }
            if($heart['ten'] >= 150){
                $variable10 = "btn-success";
            }else if($heart['ten'] < 150 && $heart['ten'] >= 1){
                $variable10 = "btn-warning";
            }else if($heart['ten'] < 1){
                $variable10 = "btn-danger";
            }
            if($heart['eleven'] >= 150){
                $variable11 = "btn-success";
            }else if($heart['eleven'] < 150 && $heart['eleven'] >= 1){
                $variable11 = "btn-warning";
            }else if($heart['eleven'] < 1){
                $variable11 = "btn-danger";
            }
            if($heart['twelve'] >= 150){
                $variable12 = "btn-success";
            }else if($heart['twelve'] < 150 && $heart['twelve'] >= 1){
                $variable12 = "btn-warning";
            }else if($heart['twelve'] < 1){
                $variable12 = "btn-danger";
            }
            if($heart['thirteen'] >= 150){
                $variable13 = "btn-success";
            }else if($heart['thirteen'] < 150 && $heart['thirteen'] >= 1){
                $variable13 = "btn-warning";
            }else if($heart['thirteen'] < 1){
                $variable13 = "btn-danger";
            }
            if($heart['fourteen'] >= 150){
                $variable14 = "btn-success";
            }else if($heart['fourteen'] < 150 && $heart['fourteen'] >= 1){
                $variable14 = "btn-warning";
            }else if($heart['fourteen'] < 1){
                $variable14 = "btn-danger";
            }
            if($heart['fifteen'] >= 150){
                $variable15 = "btn-success";
            }else if($heart['fifteen'] < 150 && $heart['fifteen'] >= 1){
                $variable15 = "btn-warning";
            }else if($heart['fifteen'] < 1){
                $variable15 = "btn-danger";
            }
            if($heart['sixteen'] >= 150){
                $variable16 = "btn-success";
            }else if($heart['sixteen'] < 150 && $heart['sixteen'] >= 1){
                $variable16 = "btn-warning";
            }else if($heart['sixteen'] < 1){
                $variable16 = "btn-danger";
            }
            if($heart['seventeen'] >= 150){
                $variable17 = "btn-success";
            }else if($heart['seventeen'] < 150 && $heart['seventeen'] >= 1){
                $variable17 = "btn-warning";
            }else if($heart['seventeen'] < 1){
                $variable17 = "btn-danger";
            }
            if($heart['eiighteen'] >= 150){
                $variable18 = "btn-success";
            }else if($heart['eiighteen'] < 150 && $heart['eiighteen'] >= 1){
                $variable18 = "btn-warning";
            }else if($heart['eiighteen'] < 1){
                $variable18 = "btn-danger";
            }
            if($heart['nineteen'] >= 150){
                $variable19 = "btn-success";
            }else if($heart['nineteen'] < 150 && $heart['nineteen'] >= 1){
                $variable19 = "btn-warning";
            }else if($heart['nineteen'] < 1){
                $variable19 = "btn-danger";
            }
            if($heart['twenty'] >= 150){
                $variable20 = "btn-success";
            }else if($heart['twenty'] < 150 && $heart['twenty'] >= 1){
                $variable20 = "btn-warning";
            }else if($heart['twenty'] < 1){
                $variable20 = "btn-danger";
            }
            if($heart['twenty_one'] >= 150){
                $variable21 = "btn-success";
            }else if($heart['twenty_one'] < 150 && $heart['twenty_one'] >= 1){
                $variable21 = "btn-warning";
            }else if($heart['twenty_one'] < 1){
                $variable21 = "btn-danger";
            }
            if($heart['twenty_two'] >= 150){
                $variable22 = "btn-success";
            }else if($heart['twenty_two'] < 150 && $heart['twenty_two'] >= 1){
                $variable22 = "btn-warning";
            }else if($heart['twenty_two'] < 1){
                $variable22 = "btn-danger";
            }
            if($heart['twenty_three'] >= 150){
                $variable23 = "btn-success";
            }else if($heart['twenty_three'] < 150 && $heart['twenty_three'] >= 1){
                $variable23 = "btn-warning";
            }else if($heart['twenty_three'] < 1){
                $variable23 = "btn-danger";
            }
            if($heart['twenty_four'] >= 150){
                $variable24 = "btn-success";
            }else if($heart['twenty_four'] < 150 && $heart['twenty_four'] >= 1){
                $variable24 = "btn-warning";
            }else if($heart['twenty_four'] < 1){
                $variable24 = "btn-danger";
            }
            if($heart['twenty_five'] >= 150){
                $variable25 = "btn-success";
            }else if($heart['twenty_five'] < 150 && $heart['twenty_five'] >= 1){
                $variable25 = "btn-warning";
            }else if($heart['twenty_five'] < 1){
                $variable25 = "btn-danger";
            }
            if($heart['twenty_six'] >= 150){
                $variable26 = "btn-success";
            }else if($heart['twenty_six'] < 150 && $heart['twenty_six'] >= 1){
                $variable26 = "btn-warning";
            }else if($heart['twenty_six'] < 1){
                $variable26 = "btn-danger";
            }
            if($heart['twenty_seven'] >= 150){
                $variable27 = "btn-success";
            }else if($heart['twenty_seven'] < 150 && $heart['twenty_seven'] >= 1){
                $variable27 = "btn-warning";
            }else if($heart['twenty_seven'] < 1){
                $variable27 = "btn-danger";
            }
            if($heart['twenty_eight'] >= 150){
                $variable28 = "btn-success";
            }else if($heart['twenty_eight'] < 150 && $heart['twenty_eight'] >= 1){
                $variable28 = "btn-warning";
            }else if($heart['twenty_eight'] < 1){
                $variable28 = "btn-danger";
            }
            if($heart['twenty_nine'] >= 150){
                $variable29 = "btn-success";
            }else if($heart['twenty_nine'] < 150 && $heart['twenty_nine'] >= 1){
                $variable29 = "btn-warning";
            }else if($heart['twenty_nine'] < 1){
                $variable29 = "btn-danger";
            }
            if($heart['thirty'] >= 150){
                $variable30 = "btn-success";
            }else if($heart['thirty'] < 150 && $heart['thirty'] >= 1){
                $variable30 = "btn-warning";
            }else if($heart['thirty'] < 1){
                $variable30 = "btn-danger";
            }
            if($heart['thirty_one'] >= 150){
                $variable31 = "btn-success";
            }else if($heart['thirty_one'] < 150 && $heart['thirty_one'] >= 1){
                $variable31 = "btn-warning";
            }else if($heart['thirty_one'] < 1){
                $variable31 = "btn-danger";
            }
            if($heart['thirty_two'] >= 150){
                $variable32 = "btn-success";
            }else if($heart['thirty_two'] < 150 && $heart['thirty_two'] >= 1){
                $variable32 = "btn-warning";
            }else if($heart['thirty_two'] < 1){
                $variable32 = "btn-danger";
            }
            if($heart['thirty_three'] >= 150){
                $variable33 = "btn-success";
            }else if($heart['thirty_three'] < 150 && $heart['thirty_three'] >= 1){
                $variable33 = "btn-warning";
            }else if($heart['thirty_three'] < 1){
                $variable33 = "btn-danger";
            }
            if($heart['thirty_four'] >= 150){
                $variable34 = "btn-success";
            }else if($heart['thirty_four'] < 150 && $heart['thirty_four'] >= 1){
                $variable34 = "btn-warning";
            }else if($heart['thirty_four'] < 1){
                $variable34 = "btn-danger";
            }
            if($heart['thirty_five'] >= 150){
                $variable35 = "btn-success";
            }else if($heart['thirty_five'] < 150 && $heart['thirty_five'] >= 1){
                $variable35 = "btn-warning";
            }else if($heart['thirty_five'] < 1){
                $variable35 = "btn-danger";
            }
            if($heart['thirty_six'] >= 150){
                $variable36 = "btn-success";
            }else if($heart['thirty_six'] < 150 && $heart['thirty_six'] >= 1){
                $variable36 = "btn-warning";
            }else if($heart['thirty_six'] < 1){
                $variable36 = "btn-danger";
            }
            if($heart['thirty_seven'] >= 150){
                $variable37 = "btn-success";
            }else if($heart['thirty_seven'] < 150 && $heart['thirty_seven'] >= 1){
                $variable37 = "btn-warning";
            }else if($heart['thirty_seven'] < 1){
                $variable37 = "btn-danger";
            }
            if($heart['thirty_eight'] >= 150){
                $variable38 = "btn-success";
            }else if($heart['thirty_eight'] < 150 && $heart['thirty_eight'] >= 1){
                $variable38 = "btn-warning";
            }else if($heart['thirty_eight'] < 1){
                $variable38 = "btn-danger";
            }
            if($heart['thirty_nine'] >= 150){
                $variable39 = "btn-success";
            }else if($heart['thirty_nine'] < 150 && $heart['thirty_nine'] >= 1){
                $variable39 = "btn-warning";
            }else if($heart['thirty_nine'] < 1){
                $variable39 = "btn-danger";
            }
            if($heart['forty'] >= 150){
                $variable40 = "btn-success";
            }else if($heart['forty'] < 150 && $heart['forty'] >= 1){
                $variable40 = "btn-warning";
            }else if($heart['forty'] < 1){
                $variable40 = "btn-danger";
            }
            if($heart['forty_one'] >= 150){
                $variable41 = "btn-success";
            }else if($heart['forty_one'] < 150 && $heart['forty_one'] >= 1){
                $variable41 = "btn-warning";
            }else if($heart['forty_one'] < 1){
                $variable41 = "btn-danger";
            }
            if($heart['forty_two'] >= 150){
                $variable42 = "btn-success";
            }else if($heart['forty_two'] < 150 && $heart['forty_two'] >= 1){
                $variable42 = "btn-warning";
            }else if($heart['forty_two'] < 1){
                $variable42 = "btn-danger";
            }
            if($heart['forty_three'] >= 150){
                $variable43 = "btn-success";
            }else if($heart['forty_three'] < 150 && $heart['forty_three'] >= 1){
                $variable43 = "btn-warning";
            }else if($heart['forty_three'] < 1){
                $variable43 = "btn-danger";
            }
            if($heart['forty_four'] >= 150){
                $variable44 = "btn-success";
            }else if($heart['forty_four'] < 150 && $heart['forty_four'] >= 1){
                $variable44 = "btn-warning";
            }else if($heart['forty_four'] < 1){
                $variable44 = "btn-danger";
            }
            if($heart['forty_five'] >= 150){
                $variable45 = "btn-success";
            }else if($heart['forty_five'] < 150 && $heart['forty_five'] >= 1){
                $variable45 = "btn-warning";
            }else if($heart['forty_five'] < 1){
                $variable45 = "btn-danger";
            }
            if($heart['forty_six'] >= 150){
                $variable46 = "btn-success";
            }else if($heart['forty_six'] < 150 && $heart['forty_six'] >= 1){
                $variable46 = "btn-warning";
            }else if($heart['forty_six'] < 1){
                $variable46 = "btn-danger";
            }
            if($heart['forty_seven'] >= 150){
                $variable47 = "btn-success";
            }else if($heart['forty_seven'] < 150 && $heart['forty_seven'] >= 1){
                $variable47 = "btn-warning";
            }else if($heart['forty_seven'] < 1){
                $variable47 = "btn-danger";
            }

            $str = '<p>'.$heart["currentTime"].'</p>
            <button type="button" class="btn btn-sm '.$variable.'">00:00<br/>'.$heart["zero"].'</button>
            <button type="button" class="btn btn-sm '.$variable1.'">00:30<br/>'.$heart["one"].'</button>
            <button type="button" class="btn btn-sm '.$variable2.'">01:00<br/>'.$heart["two"].'</button>
            <button type="button" class="btn btn-sm '.$variable3.'">01:30<br/>'.$heart["three"].'</button>
            <button type="button" class="btn btn-sm '.$variable4.'">02:00<br/>'.$heart["four"].'</button>
            <button type="button" class="btn btn-sm '.$variable5.'">02:30<br/>'.$heart["five"].'</button>
            <button type="button" class="btn btn-sm '.$variable6.'">03:00<br/>'.$heart["six"].'</button>
            <button type="button" class="btn btn-sm '.$variable7.'">03:30<br/>'.$heart["seven"].'</button><br/><br/>
            <button type="button" class="btn btn-sm '.$variable8.'">04:00<br/>'.$heart["eight"].'</button>
            <button type="button" class="btn btn-sm '.$variable9.'">04:30<br/>'.$heart["nine"].'</button>
            <button type="button" class="btn btn-sm '.$variable10.'">05:00<br/>'.$heart["ten"].'</button>
            <button type="button" class="btn btn-sm '.$variable11.'">05:30<br/>'.$heart["eleven"].'</button>
            <button type="button" class="btn btn-sm '.$variable12.'">06:00<br/>'.$heart["twelve"].'</button>
            <button type="button" class="btn btn-sm '.$variable13.'">06:30<br/>'.$heart["thirteen"].'</button>
            <button type="button" class="btn btn-sm '.$variable14.'">07:00<br/>'.$heart["fourteen"].'</button>
            <button type="button" class="btn btn-sm '.$variable15.'">07:30<br/>'.$heart["fifteen"].'</button><br/><br/>
            <button type="button" class="btn btn-sm '.$variable16.'">08:00<br/>'.$heart["sixteen"].'</button>
            <button type="button" class="btn btn-sm '.$variable17.'">08:30<br/>'.$heart["seventeen"].'</button>
            <button type="button" class="btn btn-sm '.$variable18.'">09:00<br/>'.$heart["eiighteen"].'</button>
            <button type="button" class="btn btn-sm '.$variable19.'">09:30<br/>'.$heart["nineteen"].'</button>
            <button type="button" class="btn btn-sm '.$variable20.'">10:00<br/>'.$heart["twenty"].'</button>
            <button type="button" class="btn btn-sm '.$variable21.'">10:30<br/>'.$heart["twenty_one"].'</button>
            <button type="button" class="btn btn-sm '.$variable22.'">11:00<br/>'.$heart["twenty_two"].'</button>
            <button type="button" class="btn btn-sm '.$variable23.'">11:30<br/>'.$heart["twenty_three"].'</button><br/><br/>
            <button type="button" class="btn btn-sm '.$variable24.'">12:00<br/>'.$heart["twenty_four"].'</button>
            <button type="button" class="btn btn-sm '.$variable25.'">12:30<br/>'.$heart["twenty_five"].'</button>
            <button type="button" class="btn btn-sm '.$variable26.'">13:00<br/>'.$heart["twenty_six"].'</button>
            <button type="button" class="btn btn-sm '.$variable27.'">13:30<br/>'.$heart["twenty_seven"].'</button>
            <button type="button" class="btn btn-sm '.$variable28.'">14:00<br/>'.$heart["twenty_eight"].'</button>
            <button type="button" class="btn btn-sm '.$variable29.'">14:30<br/>'.$heart["twenty_nine"].'</button>
            <button type="button" class="btn btn-sm '.$variable30.'">15:00<br/>'.$heart["thirty"].'</button>
            <button type="button" class="btn btn-sm '.$variable31.'">15:30<br/>'.$heart["thirty_one"].'</button><br/><br/>
            <button type="button" class="btn btn-sm '.$variable32.'">16:00<br/>'.$heart["thirty_two"].'</button>
            <button type="button" class="btn btn-sm '.$variable33.'">16:30<br/>'.$heart["thirty_three"].'</button>
            <button type="button" class="btn btn-sm '.$variable34.'">17:00<br/>'.$heart["thirty_four"].'</button>
            <button type="button" class="btn btn-sm '.$variable35.'">17:30<br/>'.$heart["thirty_five"].'</button>
            <button type="button" class="btn btn-sm '.$variable36.'">18:00<br/>'.$heart["thirty_six"].'</button>
            <button type="button" class="btn btn-sm '.$variable37.'">18:30<br/>'.$heart["thirty_seven"].'</button>
            <button type="button" class="btn btn-sm '.$variable38.'">19:00<br/>'.$heart["thirty_eight"].'</button>
            <button type="button" class="btn btn-sm '.$variable39.'">19:30<br/>'.$heart["thirty_nine"].'</button><br/><br/>
            <button type="button" class="btn btn-sm '.$variable40.'">20:00<br/>'.$heart["forty"].'</button>
            <button type="button" class="btn btn-sm '.$variable41.'">20:30<br/>'.$heart["forty_one"].'</button>
            <button type="button" class="btn btn-sm '.$variable42.'">21:00<br/>'.$heart["forty_two"].'</button>
            <button type="button" class="btn btn-sm '.$variable43.'">21:30<br/>'.$heart["forty_three"].'</button>
            <button type="button" class="btn btn-sm '.$variable44.'">22:00<br/>'.$heart["forty_four"].'</button>
            <button type="button" class="btn btn-sm '.$variable45.'">22:30<br/>'.$heart["forty_five"].'</button>
            <button type="button" class="btn btn-sm '.$variable46.'">23:00<br/>'.$heart["forty_six"].'</button>
            <button type="button" class="btn btn-sm '.$variable47.'">23:30<br/>'.$heart["forty_seven"].'</button><br/><br/>
        ';
        echo $str;
        exit;
        }
    }
}
